//
//  HJJPlayerWebView.m
//  Pianke
//
//  Created by 黄俊杰 on 15/12/29.
//  Copyright © 2015年 dada. All rights reserved.
//

#import "HJJPlayerWebView.h"

@implementation HJJPlayerWebView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createWeb];
    }
    return self;
}

-(void)createWeb{
    
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 375 * EACH_WIDTH, 437 * EACH_HEIGHT)];
    self.webView.backgroundColor = [UIColor clearColor];
    self.webView.delegate = self;
    [self addSubview:self.webView];
    
    
}

-(void)sendUrlStr:(NSString *)urlStr{

    NSString *urlString = [NSString stringWithFormat:@"%@",urlStr];
    NSURL *url = [NSURL URLWithString:urlString];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [self.webView loadRequest:request];
    self.webView.opaque = NO; //不设置这个值 页面背景始终是白色
    
    self.webView.backgroundColor = [UIColor clearColor];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
    //字体颜色
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= '#f0f8ff'"];
    //页面背景色
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#1A2C3B'"];
}

@end
